package com.somsoft.handjc.activity.query;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

import com.somsoft.handjc.activity.BaseGridViewActivity;
import com.somsoft.handjc.activity.R;
import com.somsoft.handjc.activity.query.xuncha.ZhongHeQueryActivity;
import com.somsoft.handjc.activity.query.xzsp.XzspQueryMainActivity;
import com.somsoft.handjc.activity.query.xzzf.XzzfZhongHeQueryActivity;
import com.somsoft.handjc.activity.rank.RankActivity;
import com.somsoft.handjc.activity.rank.xuncha.JiXiaoRankActivity;
import com.somsoft.handjc.util.MyApplication;
import com.somsoft.handjc.util.Utils;

@SuppressWarnings("all")
public class QueryActivity extends BaseGridViewActivity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyApplication.getInstance().addActivity(this);
		setContentView(R.layout.gridview);
		GridView gridview = (GridView) findViewById(R.id.gridview);
		Integer[] pics = {R.drawable.d1, R.drawable.d2, R.drawable.d3, R.drawable.d4,R.drawable.d5 };
		String[] titles = {"效能巡查查询","行政执法查询","行政审批查询","公共资源查询","重大项目查询"};
		super.createGridView(gridview,pics,titles);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		boolean flag = false;
		Intent it = null;
		switch (arg2) {
		case 0:
			flag = Utils.isPass(Utils.USER_LEVEL, ZhongHeQueryActivity.class);
			if(flag){
				it = new Intent(QueryActivity.this,ZhongHeQueryActivity.class);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		case 1:
			flag = Utils.isPass(Utils.USER_LEVEL, XzzfZhongHeQueryActivity.class);
			if(flag){
				it = new Intent(QueryActivity.this,XzzfZhongHeQueryActivity.class);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		case 2:
			flag = Utils.isPass(Utils.USER_LEVEL, XzspQueryMainActivity.class);
			if(flag){
				it = new Intent(QueryActivity.this,XzspQueryMainActivity.class);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		default:
			Toast t = Toast.makeText(this, "该功能开发中！", Toast.LENGTH_SHORT);
			t.setGravity(Gravity.CENTER, 0, 0);
			t.show();
			break;
		}
		if(it != null){
			Utils.openLoading(QueryActivity.this);
			startActivity(it);
		}
	}
}